﻿
<!--
/**************************************************
* @ manufactureinsert.jsp
*
* Copyright   2005 Hitrust Technology Inc.
* Developed by SDC, Hitrust.
* All Rights Reserved.
*
* Modify History:
*  v1.00, 2006/02/13, Simonyi Peng
*  1) first release
/**************************************************
-->
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import="com.hitrust.gs.business.GSManufactureProcessor" %>
<%@ page import="com.hitrust.gs.bean.GSManufactureCategoryBean" %>
<%@ page import="java.util.ArrayList"%>
<%@ page import="java.util.HashMap"%>
<%@ include file="../../common.jsp" %>
<%@ taglib uri="/page.util.gs.hitrust.com/taglibs/page" prefix="page"%>

<%
			response.setHeader("Pragma", "No-cache");
			response.setHeader("Cache-Control", "no-cache,no-store,max-age=0");
			response.setDateHeader("Expires", 0);
%>
<html>
<head>
<title>新增产品</title>
<meta http-equiv="Content-Type"	content="text/html; charset=UTF-8">
<LINK href="<%=root%>/css/css.css" type=text/css rel=stylesheet>
<SCRIPT language="JavaScript" src="<%=root%>/js/common.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=root%>/js/string.js"></SCRIPT>

<%
	//取缓存的输入值
	GSManufactureInputForm tForm = (GSManufactureInputForm)request.getAttribute("buffer");
	

	GSManufactureProcessor tGSManufProcessor = new GSManufactureProcessor();
	    ArrayList tManuf1 = null;
	    ArrayList tManuf2 = null;
	    ArrayList tManuf3 = null;
		HashMap tMap1 = new HashMap();
	    HashMap tMap2 = new HashMap();
	
	try{
	    tManuf1 = tGSManufProcessor.getManufactureType("1");
	    tManuf2 = tGSManufProcessor.getManufactureType("2");
	    tManuf3 = tGSManufProcessor.getManufactureType("3");
	    
    
            if(tManuf1 != null ){
                for(int i=0; i<tManuf1.size(); i++){
                    //一级产品种类
                    GSManufactureCategoryBean tGSManufCategyBean = (GSManufactureCategoryBean)tManuf1.get(i);
                    if(tManuf2 != null){
                        ArrayList tList1 = new ArrayList();
                        for(int j=0; j<tManuf2.size();j++){
                            //二级产品种类
                            GSManufactureCategoryBean tGSManufactureBean1 = (GSManufactureCategoryBean)tManuf2.get(j);
                            if(tGSManufCategyBean.getGs_manufacture_category_id().equals(tGSManufactureBean1.getGs_upper_manufacture_category())){
                                tList1.add(tGSManufactureBean1);
                            }
                            ArrayList tList2 = new ArrayList();
                            for(int k=0; k<tManuf3.size(); k++){
                                //三级产品种类
                               GSManufactureCategoryBean tGSManufactureBean2 = (GSManufactureCategoryBean)tManuf3.get(k);
                               if(tGSManufactureBean1.getGs_manufacture_category_id().equals(tGSManufactureBean2.getGs_upper_manufacture_category())){
                                  tList2.add(tGSManufactureBean2);
                               }
                            }
                            if(tList2.size() > 0)
                                tMap2.put(""+tGSManufactureBean1.getGs_manufacture_category_id(),tList2);
                        }
                        if(tList1.size() > 0)
                            tMap1.put(""+tGSManufCategyBean.getGs_manufacture_category_id(),tList1);
                    }
                }
            }
            
	}catch(GSException e){
	    throw e;
	}catch(Exception e){
	    GSLogWriter.error(this,e.toString());
	    throw new GSException("进入产品浏览首页面发生异常");
	}
	
	//ResultProcess tGSManuf = (ResultProcess)request.getAttribute("manufacture");
%>
<script language="JavaScript">
	var counter;
	function change1(optval){
  		var val = optval;
		if(val=='0'){
			var listbox = document.getElementById("category2");
			listbox.length = 0;
			var option = new Option();
			option.text = "---二级---";
			option.value = "0";			
			listbox.options[listbox.length] = option;

		}else{
  	<%
  		if(tMap1 !=null){
	 	   	Collection tCollection = tMap1.keySet();
	        Iterator tIterator = tCollection.iterator();
  		       while(tIterator.hasNext()){
  		           String tKey = (String)tIterator.next();
  		           ArrayList tList = (ArrayList)tMap1.get(tKey);
  	%>
  				if(val == '<%=tKey%>'){
	  				var counter;
	  				var listbox = document.getElementById("category2");
	  				listbox.length = 0;  		  	  	
							var option = new Option();
							option.value = "0";
							option.text = "---二级---";
							listbox.options[listbox.length] = option;			  											
	<%					
						for(int n=0;n<tList.size();n++){
						    GSManufactureCategoryBean tGSManufactureBean = (GSManufactureCategoryBean)tList.get(n);
						    String categoryId = tGSManufactureBean.getGs_manufacture_category_id();
						    String categoryName = tGSManufactureBean.getGs_manufacture_category_name();
	%>				
							var temp1 = '<%=categoryId%>';
							var temp2 = '<%=categoryName%>';
							var option = new Option();
							option.value = temp1;
							option.text = temp2;
							listbox.options[listbox.length] = option;						
	<%
						}
	%>
  				}
  	<%
  		    }
  		       
  		}
  	%>
  	}	
	}	
	function change2(optval){
  		var val = optval;
		if(val=='0'){
			var listbox = document.getElementById("category3");
			listbox.length = 0;
			var option = new Option();
			option.text = "---三级---";
			option.value = "0";			
			listbox.options[listbox.length] = option;

		}else{
  	<%
  		if(tMap2 !=null){
	 	   	Collection tCollection = tMap2.keySet();
	        Iterator tIterator = tCollection.iterator();
  		       while(tIterator.hasNext()){
  		           String tKey = (String)tIterator.next();
  		           ArrayList tList = (ArrayList)tMap2.get(tKey);
  	%>
  				if(val == '<%=tKey%>'){
	  				var counter;
	  				var listbox = document.getElementById("category3");
	  				listbox.length = 0;  		  	  	
			var option = new Option();
			option.text = "---三级---";
			option.value = "0";			
			listbox.options[listbox.length] = option;	  											
	<%					
						for(int n=0;n<tList.size();n++){
						    GSManufactureCategoryBean tGSManufactureBean = (GSManufactureCategoryBean)tList.get(n);
						    String categoryId = tGSManufactureBean.getGs_manufacture_category_id();
						    String categoryName = tGSManufactureBean.getGs_manufacture_category_name();
	%>				
							var temp1 = '<%=categoryId%>';
							var temp2 = '<%=categoryName%>';
							var option = new Option();
							option.value = temp1;
							option.text = temp2;
							listbox.options[listbox.length] = option;						
	<%
						}
	%>
  				}
  	<%
  		    }
  		       
  		}
  	%>
  	}		
	}
	
</script>

<script language='javascript'>
	var counter;
	function process(){
		if(checkValue()){
			form1.action = "<%=response.encodeURL(root+"/A400304.do")%>";
			form1.submit();
		}
	}
	
	function checkValue(){
		if(document.all.manufacturecode.value == null || document.all.manufacturecode.value == ""){
			alert("请输入产品编号");
			return false;
		}
		if(document.all.manufacturename.value == null || document.all.manufacturename.value == ""){
			alert("请输入产品名称");
			return false;
		}
		if(document.all.category1.options[0].selected && document.all.category2.options[0].selected && document.all.category3.options[0].selected){
			alert("请输入产品种类");
			return false;
		}
		if(document.all.quantunit.value == null || document.all.quantunit.value == ""){
			alert("请输入产品数量单位");
			return false;
		}
		if(document.all.unitprice.value == null || document.all.unitprice.value == ""){
			alert("请输入产品单价");
			return false;
		}
		if(document.all.providerid.value == null || document.all.providerid.value == ""){
		    alert("请输入供应商");
		    return false;
		}
		if(!isFloatNum(document.all.unitprice.value)){
			alert("产品单价栏位请输入数字");
			return false;
		}
		return true;
	}
	function selectprovider(){
		var url = "<%=response.encodeURL(root+"/A100106.do")%>";
		var returnv = window.open(url,null," edge: sunken ; center: Yes; help: No; resizable: No; status: Yes; dialogWidth: 840px ; dialogHeight: 720px ; scroll:yes");
		
	}
</script>
</head>
<%
	//ArrayList orglist = (ArrayList)request.getAttribute("orglist");
	//else System.out.println(orglist.size());
%>
<body BGCOLOR="#f2f2f2"	text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<br>

<table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td height="20"> 
      <table width="100%" border="0" cellspacing="0" cellpadding="1">
        <tr height="20">
          <td height="20" width="1" class="mtxt_black">&nbsp;</td>
          <td height="30" width="758" class="mtxt_black">产品信息录入提示</td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td class="bg_line" height="2"></td>
  </tr>
</table>
<br>

<form name="form1" method="post" enctype="multipart/form-data">
<input type='hidden' name='submittype' value=''>
<table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
	<tr> 
		<td> 
			<table class=bg_table id=tableId	cellspacing=1 cellpadding=0 style="padding-left:5;padding-right:5" width=100% align=center border=0>
				<TR height=20>
					<TD class="bg_column" align=center>产品编号</TD>
					<TD align=left class="bg_row_odd"><input type="text" name="manufacturecode" value="<%=tForm==null?"":tForm.getManufacturecode()%>"></TD>					
					<TD class="bg_column" align=center>产品名称</TD>
					<TD align=left class="bg_row_odd"><input type="text" name="manufacturename" value="<%=tForm==null?"":tForm.getManufacturename()%>"></TD>					
				</TR>
				<TR height=20>
					<TD class="bg_column" align=center>产品种类</TD>
					<TD left=right class="bg_row_odd">
						<select name="category1" onChange="change1(this.value)">					
								<option value="0">------一级------</option>
						<%
							String tManufType1 = request.getParameter("manuftype1");
							//int iManuType1 = 0;
							if(tManuf1 != null && tManuf1.size() > 0 ){
							    if(tManufType1 != null){
							        //iManuType1 = Integer.parseInt(tManufType1);
							    }
								for(int i=0; i<tManuf1.size(); i++){
								    GSManufactureCategoryBean tGSManufactureBean = (GSManufactureCategoryBean)tManuf1.get(i);
								    if(tManufType1!=null && tManufType1.equals(tGSManufactureBean.getGs_manufacture_category_id())){
								        
						%>
								<option value="<%=tGSManufactureBean.getGs_manufacture_category_id()%>" selected>
								<%=tGSManufactureBean.getGs_manufacture_category_name()%></option>
						<%			        
								    }else{
						%>
								<option value="<%=tGSManufactureBean.getGs_manufacture_category_id()%>">
								<%=tGSManufactureBean.getGs_manufacture_category_name()%></option>
								
						<%			}	
								}
							}
						%>
						</select>
						<select id='category2' name="category2" onChange="change2(this.value)">					
								<option value="0">------二级------</option>
						<%
							String tManufType2 = request.getParameter("manuftype2");
							if(tManufType1 != null && !tManufType1.equals("0")){
							    //int tIntManuType2 = Integer.parseInt(tManufType2);
							    ArrayList temp = (ArrayList)tMap1.get(tManufType1);
								for(int i=0; i<temp.size(); i++){
								    GSManufactureCategoryBean tGSManuf2 = (GSManufactureCategoryBean)temp.get(i);
								    if(tManufType2!=null && tManufType2.equals(tGSManuf2.getGs_manufacture_category_id())){
						%>
								<option value="<%=tManufType2%>" selected><%=tGSManuf2.getGs_manufacture_category_name()%></option>
						<%			        
								    }else{
						%>
								<option value="<%=tGSManuf2.getGs_manufacture_category_id()%>"><%=tGSManuf2.getGs_manufacture_category_name()%></option>
								
						<%			}	
								}
							}
						%>							
						</select>
						<select id='category3' name="category3">					
								<option value="00">------三级------</option>
						<%
							String tManufType3 = request.getParameter("manuftype3");
							if(tManufType2 != null && !tManufType2.equals("0") ){
							   // int tIntManufType3 = Integer.parseInt(tManufType3);
							    ArrayList temp = (ArrayList)tMap2.get(tManufType2);
								for(int i=0; i<temp.size(); i++){
								    GSManufactureCategoryBean tGSManuf3 = (GSManufactureCategoryBean)temp.get(i);
								    if(tManufType3!=null && tManufType3.equals(tGSManuf3.getGs_manufacture_category_id())){
						%>
								<option value="<%=tGSManuf3.getGs_manufacture_category_id()%>" selected><%=tGSManuf3.getGs_manufacture_category_name()%></option>
						<%			        
								    }else{
						%>
								<option value="<%=tGSManuf3.getGs_manufacture_category_id()%>"><%=tGSManuf3.getGs_manufacture_category_name()%></option>
								
						<%			}	
								}
							}
						%>							
						</select>
					</TD>
					<TD class="bg_column" align=center>产品品牌</TD>
					<TD align=left class="bg_row_odd"><input type="text" name="manufacturebrand" value="<%=tForm==null?"":tForm.getManufacturebrand()%>"></TD>		
				</TR>
				<TR height=20>
					<TD class="bg_column" align=center>产品型号</TD>
					<TD align=left class="bg_row_odd"><input type="text" name="manufacturetype" value="<%=tForm==null?"":tForm.getManufacturetype()%>"></TD>					
					<TD class="bg_column" align=center>产品规格</TD>
					<TD align=left class="bg_row_odd"><input type="text" name="manfuacturespec" value="<%=tForm==null?"":tForm.getManfuacturespec()%>"></TD>					
				</TR>
				<TR height=20>
					<TD class="bg_column" align=center>产品单价</TD>
					<TD align=left class="bg_row_odd"><input type="text" name="unitprice" value="<%=tForm==null?"":tForm.getUnitprice()%>">&nbsp;元</TD>					
					<TD class="bg_column" align=center>数量单位</TD>
					<TD align=left class="bg_row_odd"><input type="text" name="quantunit" value="<%=tForm==null?"":tForm.getQuantunit()%>"></TD>					
				</TR>
				<TR height=20>
					<TD class="bg_column" align=center>质保期</TD>
					<TD align=left class="bg_row_odd"><input type="text" name="qualityassureperiod" value="<%=tForm==null?"":tForm.getQualityassureperiod()%>"></TD>					
					<TD class="bg_column" align=center>生产厂商</TD>
					<TD align=left class="bg_row_odd"><input type="text" name="manufacturername" value="<%=tForm==null?"":tForm.getManufacturername()%>"></TD>					
				</TR>
				<TR height=20>
					<TD class="bg_column" align=center>产地</TD>
					<TD align=left class="bg_row_odd"><input type="text" name="makearea" value="<%=tForm==null?"":tForm.getMakearea()%>"></TD>					
					<TD class="bg_column" align=center>供应商</TD>
					<TD align=left class="bg_row_odd">
					<input type="text" id='provider_name' name="gs_provider_name" value="" readonly>
					<input type="hidden" id='provider_id' name="providerid" value="">
					<input type='button' value='选择供应商' onclick='selectprovider();'></TD>					
				</TR>
				<TR height=20>
					<TD class="bg_column" align=center>产品附加属性</TD>
					<TD align=left class="bg_row_odd">
					<input type="text" name="property" value="<%=tForm==null?"":tForm.getProperty()%>"></TD>					
					<TD class="bg_column" align=center>产品图片</TD>
					<TD align=left class="bg_row_odd"><input name="manufactureimage" type='file' ></TD>					
				</TR>
				<TR height=20>
					<TD class="bg_column" align=center>备注</TD>
					<TD align=left class="bg_row_odd" colspan="3" size="50">
					<input type="text" name="remark" value="<%=tForm==null?"":tForm.getRemark()%>" size="100"></TD>					
						
				</TR>
			</table>
		</td>
	</tr>
</table>
</form>
    <p align="center">  
		<input type="image" src="<%=response.encodeURL(root+"/images/button/queding.gif")%>" width="58" height="24" class="box" onclick="process();"/>&nbsp;
		<input type="image" src="<%=response.encodeURL(root+"/images/button/quxiao.gif")%>" width="58" height="24" class="box" onclick="window.close();"/>&nbsp;
    </p>
</body>
</html>